Stop anyone from acting as an admin through the MCP token or sign-in #126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
In production,
dt-web-secrethadENABLE_MCP_HTTP_ENDPOINT=trueandMCP_TEST_USER_ROLE=admin./api/mcpand/api/tools/*are reachable from the internet and accept one shared bearer token, so anyone holding that token acted asngholizawith admin rights. The production setting is being fixed separately: the endpoint is turned off and the token deleted. This PR makes the code refuse that setup, and closes two other ways to end up as an admin.Changes
web/lib/mcp/bearer-identity.ts,dt-call.ts):MCP_TEST_USER_IDandMCP_TEST_USER_EMAIL. There is no default account anymore.researcher.admin(orAdministrator), the token is refused, and the refusal is logged.api/role_requests.py,role-request-card.tsx):require_admin).web/lib/saml/profile.ts,web/auth.ts,api/user_identity.py,api/routers/admin.py):ngholiza@other.examplebecamengholiza, was merged into that account, and kept its admin role.id_source=asserted) or was derived from the email (id_source=email). An email-derived id that matches an account with a different email is refused with a 409, before any update or merge.Tests
test_user_identity.pyandtest_platform_notifications.py. New tests cover:node --test lib/mcp/bearer-identity.test.mjspasses (3 tests: admin refused, explicit identity required, default researcher). The 18 assistant tests,tscandeslintpass.Note
DT_SYSTEM_TOKENcan still claim any identity. It's the internal credential between dt-web and dt-api and should only be in those two secrets.🤖 Generated with Claude Code